﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BEGDC.PreContract.BLL;

namespace PreContractWeb.UserControl
{
    public partial class Title : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get System Time
            System.DateTime date=System.DateTime.Now;
            lblCurrentTime.CssClass = "title_deadline";
            lblCurrentTime.Text = date.ToString("yyyy-MM-dd") + " " + date.DayOfWeek.ToString();

            //Get User Name

            BEGDC.PreContract.BLL.Authentication.PCIdentity user = new BEGDC.PreContract.BLL.Authentication.PCIdentity(HttpContext.Current.User.Identity);
            lblUser.Text = user.Name.ToString();


            //Get Last Login Time

            BEGDC.PreContract.BLL.IOperationLog logservice = (BEGDC.PreContract.BLL.IOperationLog)BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.PreContract.BLL.Services.CONST_OperationLog_Service];
            string lastLogin = logservice.GetLastLoginTime("OperationType='" + BEGDC.PreContract.BLL.OperationLog.OperationType.Login.ToString() + "' AND EmployeeName = '" + user.Name.ToString()+ "'");
            if (lastLogin != string.Empty)
            {
                date = System.Convert.ToDateTime(lastLogin);
                lbllastLoginTime.Text = date.ToString("yyyy-MM-dd") + " " + date.ToShortTimeString();
            }


            //Get latest deadline

            lblDeadline.CssClass = "title_deadline";

            lblDeadline.Text = ReportHelper.GetReportDeadline();

        }
    }
}